import Vue from 'vue'
import VueRouter from 'vue-router'
import Film from '@/views/Film.vue'
import Cinema from '@/views/Cinema.vue'
import Center from '@/views/Center.vue'
import Nowplaying from '@/views/Film/Nowplaying.vue'
import Comingsoon from '@/views/Film/Comingsoon'
import Detail from "../views/Detail";
import City from "../views/City";
import Search from "../views/Search";


Vue.use(VueRouter)

const routes = [
    {
        path: '/film',
        component: Film,
        children: [
            {
                path: 'nowplaying',
                component: Nowplaying
            },
            {
                path: 'comingsoon',
                component: Comingsoon
            },
            {
                path: '',
                redirect: '/film/nowplaying'
            }
        ]
    },
    {
        path: '/cinema',
        component: Cinema
    },
    {
        path: '/cinema/search',
        component: Search
    },
    {
        path: '/center',
        component: Center
    },
    {
        path: '/detail/:id',//动态路由
        component: Detail,
    },
    {
        path: '/login',
        component: () => import('@/views/Login') //路由懒加载
    },
    {
        path: '*',
        redirect: '/film'
    }, {
        path: '/detail',
        component: Detail
    }, {
        path: '/city',
        component: City
    }
]

const router = new VueRouter({
    // mode history表示路径没#
    mode: 'history',
    routes
})

export default router
